package cn.quevo.beetlsql.dao;

import java.util.List;

import cn.quevo.core.entity.DoEntity;
import cn.quevo.core.entity.PageResult;
import cn.quevo.core.entity.query.QueryPage;
import cn.quevo.core.enums.ResultStatusEnum;
import cn.quevo.core.exception.CustomException;

/**
 * 基础Dao接口
 *
 * @param <T> DO对象，和数据库对应
 * @param <Q> Query 查询对象
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2017年12月14日 下午11:27:18
 * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
 */
public interface BasicRepository<T extends DoEntity, Q extends QueryPage> {

    /**
     * 创建对象
     *
     * @param entity
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 18:27:22
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default Integer create(T entity){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 更新对象
     *
     * @param entity
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:17:15
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default Integer update(T entity){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 逻辑删除
     *
     * @param entity
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:26:15
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default Integer remove(T entity){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 物理删除
     *
     * @param entity
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:28:49
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default Integer delete(T entity){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 获取单个对象
     *
     * @param query
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:27:00
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default <E> E getSinge(Q query){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 列表查询
     *
     * @param query
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:27:31
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default <E>List<E> getList(Q query){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 分页查询
     *
     * @param query
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:27:38
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    default <E>PageResult<E> getPage(Q query){
        throw new CustomException(ResultStatusEnum.METHOD_NOT_EXISTS);
    }

    /**
     * 获取SQL 前缀
     *
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 19:27:58
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    String getSqlPre();
}
